#include <bits/stdc++.h>

using namespace std;

std::vector<int> v;

int main(int argc, char const *argv[])
{
	int T;scanf("%d",&T);
	int n,k,D;scanf("%d%d%d",&n,&k,&D);
	for (int i = 0; i < n; ++i)
	{
		int a,b;scanf("%d%d",&a,&b);
		int tmp=(a%(D-b))==0?(a/(D-b)):(a/(D-b))+1;
		v.emplace_back(tmp);
	}
	sort(v.begin(),v.end());
	int ans=0;
	for (int i = 0; i < k; ++i)
	{
		ans+=v[i];
	}
	printf("%d\n",ans);
	return 0;
}